package servlet;

import eneity.News;
import service.UserManage;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class addCommentsServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        News news=new News();
        UserManage us=new UserManage();
        news.setNid(req.getParameter("nid"));
        news.setNewsComments(req.getParameter("comment"));
        us.addComments(news);
        req.getRequestDispatcher("newsdetail").forward(req,resp);
    }
}
